<template>
  <div class="app-container">

    <el-table
      ref="multipleTable"
      v-loading="listLoading"
      :data="list"
      :element-loading-text="$t('table.load')"
      border
      fit
      highlight-current-row
    >
      <el-table-column align="center" label="Id" width="95">
        <template slot-scope="scope">
          {{ scope.row.id }}
        </template>
      </el-table-column>
      <el-table-column :label="$t('task.type')">
        <template slot-scope="scope">
          {{ scope.row.change_type_text }}
        </template>
      </el-table-column>
      <el-table-column :label="$t('user.number')">
        <template slot-scope="scope">
          <svg-icon v-if="scope.row.change_type == 1 || scope.row.change_type == 3" icon-class="add-fill" class-name="card-panel-icon icon-add" />
          <svg-icon v-else icon-class="reduce-fill" class-name="card-panel-icon icon-reduce" />
          {{ scope.row.change_integral }}
        </template>

      </el-table-column>
      <el-table-column :label="$t('user.createTime')">
        <template slot-scope="scope">
          {{ scope.row.created_at }}
        </template>
      </el-table-column>
    </el-table>
    <pagination v-show="total>0" :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.limit" @pagination="getList" />
  </div>
</template>

<script>
import { walletLog } from '@/api/user'
import Pagination from '@/components/Pagination'

export default {
  name: 'SelectExcel',
  components: { Pagination },
  data() {
    return {
      list: null,
      total: 0,
      listQuery: {
        page: 1,
        limit: 10,
        importance: undefined,
        title: undefined,
        type: undefined,
        sort: '+id'
      },
      listLoading: true,
      multipleSelection: [],
      downloadLoading: false,
      filename: ''
    }
  },
  created() {
    this.getList()
  },
  methods: {
    getList() {
      this.listLoading = true
      walletLog({
        page: this.listQuery.page,
        limit: this.listQuery.limit
      }).then(response => {
        this.list = response.data.list
        this.total = response.data.total
        this.listLoading = false
      })
    },
    typeFormat(row, column, cellValue, index) {
      return { 1: this.$t('walletDetails.recharge'), 2: this.$t('walletDetails.campaign'), 3: this.$t('walletDetails.refund'),
        4: this.$t('walletDetails.freeze'), 5: this.$t('walletDetails.transfer') }[cellValue]
    }
  }
}
</script>
<style lang="scss" scoped>
.icon-add {
  color: #40c9c6;
}
.icon-reduce {
  color: #f4516c;
}
</style>
